package cn.eonshine.cuba.lsms.modular.biz.service.impl;

import java.util.Calendar;
import java.util.Date;

import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cn.eonshine.cuba.lsms.modular.biz.entity.InfRealTimeDataOff;
import cn.eonshine.cuba.lsms.modular.biz.mapper.InfRealTimeDataOffMapper;
import cn.eonshine.cuba.lsms.modular.biz.service.IInfRealTimeDataOffService;

@Service
@Transactional
public class InfRealTimeDataOffServiceImpl extends ServiceImpl<InfRealTimeDataOffMapper, InfRealTimeDataOff>
		implements IInfRealTimeDataOffService {

	@Override
	public boolean isClosed(Date bussinessDate) {
		QueryWrapper<InfRealTimeDataOff> query = new QueryWrapper<InfRealTimeDataOff>();
		bussinessDate = DateUtils.truncate(bussinessDate, Calendar.DAY_OF_MONTH);
		query.lambda().eq(InfRealTimeDataOff::getRealDataDate, bussinessDate)
			.eq(InfRealTimeDataOff::getStatus,InfRealTimeDataOff.STATUS_TYPE.close);
		
		int count = this.baseMapper.selectCount(query);
		boolean flag = false;
		if (count > 0) {
			flag = true;
		}
		return flag;  
	}

}
